package rctgl;

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.RandomAccessFile;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.File;
import java.util.Properties;

import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.swing.JFileChooser;

import panoramic.textures.TextureManager;



import com.sun.opengl.util.Animator;

import rctgl.util.RLEInputStream;
import rctgl.util.RLEDecoder;
import rctgl.park.RCTGLTextures;
import rctgl.park.sv4.SV4Park;

public class RCTGLTest
{

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception
	{
		System.out.println("RCTGL");
		
		SV4Park testPark = RCTGLRenderer.selectParkFromDisk();
		
		
		try
        {
            Frame testFrame = new Frame("TestFrame");
            testFrame.setSize( 512, 384 );
            
            
            GLCapabilities caps = new GLCapabilities();
            caps.setRedBits(8);
            caps.setBlueBits(8);
            caps.setGreenBits(8);
            caps.setAlphaBits(8);
            caps.setHardwareAccelerated(true);
            
            GLCanvas canvas = new GLCanvas(caps);
            testFrame.add( canvas );
            
            
            
            RCTGLRenderer renderer = new RCTGLRenderer();
            
            if(testPark != null)
            	renderer.setRenderObject( testPark.getScene() );
            
            

            canvas.addGLEventListener( renderer );

            final Animator animator = new Animator( canvas);
            testFrame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                  animator.stop();
                  System.exit(0);
                }
              });
            testFrame.show();
            animator.start();
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
		

	}

}
